package com.itheima.stock.service.imp;

import com.itheima.stock.common.domian.StockBlockDomain;
import com.itheima.stock.mapper.StockBlockRtInfoMapper;
import com.itheima.stock.service.StockBlockService;
import com.itheima.stock.utils.DateTimeUtil;
import com.itheima.stock.vo.result.R;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author: siwukun
 * @date: 2022/06/01
 * @description: 板块指数
 */

@Service
public class StockBlockServiceImpl implements StockBlockService {

    @Autowired
    private StockBlockRtInfoMapper stockBlockRtInfoMapper;


    @Override
    public R<List<StockBlockDomain>> queryAllStockBlock() {
        //查询条数 方便解耦合
        Integer number = 10;
        //2.获取最近股票交易日期
        Date lastDate = DateTimeUtil.getLastDate4Stock(DateTime.now()).toDate();
        lastDate = DateTime.parse("2022-01-03 09:30:00", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate();
        List<StockBlockDomain> list = stockBlockRtInfoMapper.queryAllStockBlock(lastDate,number);
        return R.ok(list);
    }
}
